package com.miyake.client;

import java.util.List;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
import com.miyake.client.datamanage.Alias;
import com.miyake.client.datamanage.AnalysisSetup;
import com.miyake.client.datamanage.Data;
import com.miyake.client.datamanage.NodeProperty;
import com.miyake.client.datamanage.Paper;
import com.miyake.client.datamanage.PlotData;
import com.miyake.client.datamanage.PlotSetting;
import com.miyake.client.datamanage.Table;
import com.miyake.client.datamanage.Text;
import com.miyake.client.datamanage.plugin.PluginProperty;

@RemoteServiceRelativePath("DataService")
public interface DataService extends RemoteService {
	/**
	 * Utility class for simplifying access to the instance of async service.
	 */
	public static class Util {
		private static DataServiceAsync instance;
		public static DataServiceAsync getInstance(){
			if (instance == null) {
				instance = GWT.create(DataService.class);
			}
			return instance;
		}
	}
	
	// Root Node
	String createRootNode(String name);
	void renameRootNode(String key, String name);
	List<NodeProperty> getRootNodes(String userKey);
	NodeProperty getRootNode(String subNode);
	
	// Node
	String createNode(String name, String parentKey);
	void renameNode(String key, String name);
	List<NodeProperty> getSubNodes(String key);
	List<NodeProperty> getSpecifiedSubNodes(String key, Integer type);
	NodeProperty getNode(String key);
	void moveNodeUp(String key);
	void moveNodeDown(String key);
	void setSecurityLevel(String nodeKey, Integer level);
	List<NodeProperty> getOpenDataList(String userKey);
	
	// Data
	Data getData(String key);
	void setAnalysisPlugin(String nodeKey, String pluginKey);
	
	// Delete
	void deleteNode(String key);
	void updateData(String nodeKey, Data data);
	void deleteNodes(List<String> keys);
	
	// Plot Data
	String createPlot(String name, String parentKey, Integer xcol, Integer ycol);
	PlotData getPlot(String nodeKey, Integer count);
	String getPlotURL(String nodeKey, Integer count, Integer height);
	void updatePlot(String nodeKey, PlotSetting scale);
	List<NodeProperty> getPlotList(String nodeKey);
	String addPlotOverlay(String nodeKey, String overlayNodeKey);
	void deletePlotOverLay(String nodeKey, String overlayNodeKey);
	
	// Text
	String createText(String name, String parentKey, Text data, Integer order);
	void updateText(String nodeKey, Text data);
	Text getText(String nodeKey);
	
	// Table
	String createTable(String name, String parentKey);
	Table getTable(String nodeKey);
	
	// Image
	String getImage(String nodeKey);
	List<NodeProperty> getImageList(String nodeKey);
	
	// Paper
	String createPaper(String name, String parentKey);
	Paper getPaper(String nodeKey);
	List<Paper> getPaperList(String communityKey);
	
	// Alias
	String createAlias(String nodeKey, String key, Integer type);
	Alias getAlias(String nodeKey);
	
	// Plugin
	String addFilePlugin(String url);
	List<PluginProperty> getFilePluginList();
	
	String addAnalysisPlugin(String url);
	List<PluginProperty> getAnalysisPluginList();

	String addChartPlugin(String url);
	List<PluginProperty> getChartPluginList();
	
	void deletePlugin(String key);
	PluginProperty getPlugin(String key);
	String doAnalysis(String nodeKey, String pluginKey, AnalysisSetup setup, Integer column);
	String doReAnalysis(String nodeKey, String pluginKey, AnalysisSetup setup);
	AnalysisSetup getAnalysisParameters(String url);
	AnalysisSetup getMyAnalysisParameters(String nodeKey, String url);
	void setFilePlugin(String nodeKey, String pluginKey);
	void doParse(String nodeKey);
}
